% !TeX root = ../Mao.tex

%%%% TikZ 定制的章节样式 
\usepackage[explicit]{titlesec}
\usepackage{tikz}
\usetikzlibrary{positioning, calc}

\definecolor{chcor1}{HTML}{57C3CF}
\definecolor{chcor2}{HTML}{4EA8B1}

\definecolor{secor1}{HTML}{57C3CF}
\definecolor{secor2}{HTML}{4EA8B1}

\titleformat{\chapter}
{\normalfont}{}{0em}
{\ChapTitle{east}{west}{0\paperwidth}{#1}}

\titleformat{\section}
{\normalfont}{}{0em}
{\SecTitle{east}{west}{0\paperwidth}{#1}}

\newcommand\ChapTitle[4]{%
    \begin{tikzpicture}
        \node (A) [rectangle,minimum width=\textwidth, minimum height=1cm,color=white,fill=chcor2, text width=\textwidth-3cm,align=left] {\hspace{1.5cm}\parbox{\textwidth}{\huge\textbf{\textsf{#4}}}};
        \fill[fill=chcor1] (A.north west) -- ($(A.north west)+(1.5cm,0)$) -- ($0.5*(A.north west)-0.5*(A.north west)-(0.5*\textwidth-2.5cm,0)$)--($(A.south west)+(1.5cm,0)$)--(A.south west);
        \node [color=white](A.north west) at ($0.5*(A.north west)-0.5*(A.north west)-(0.5*\textwidth-1cm,0)$) {\Huge\textbf{\textsf{\CTEXthechapter}}};
\end{tikzpicture}
}

\newcommand\SecTitle[4]{%
    \begin{tikzpicture}
\node (A) [rectangle,minimum width=\textwidth, minimum height=1cm,color=white,fill=secor2, text width=\textwidth-3cm,align=left] {\hspace{1.5cm}\parbox{\textwidth}{\huge\textbf{\textsf{#4}}}};
        \fill[fill=secor1] (A.north west) -- ($(A.north west)+(1.5cm,0)$) -- ($0.5*(A.north west)-0.5*(A.north west)-(0.5*\textwidth-2.5cm,0)$)--($(A.south west)+(1.5cm,0)$)--(A.south west);
        \node [color=white](A.north west) at ($0.5*(A.north west)-0.5*(A.north west)-(0.5*\textwidth-1cm,0)$) {\Huge\textbf{\textsf{\CTEXthesection}}};
\end{tikzpicture}

}